package com.example.test.controller;

import com.example.test.pojo.Student;
import com.example.test.service.StudentService;
import com.example.test.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Cavan
 * @date 2023-06-14
 * @qq 2069543852
 */
@RestController
public class StudentController {
    @Autowired
    private StudentService studentService;

    //http://localhost:8888/student
    @GetMapping("/student")
    public Result getAllStu(){
        List<Student> allStu = studentService.getAllStu();
        //allStu不为空，则查询成功
        if (!ObjectUtils.isEmpty(allStu)){
            return Result.ok(allStu);
        }else {
            return Result.ok("没有查询数据");
        }
    }




}
